/*
 * @Description: 
 * @Author: chenjiaxin
 * @Date: 2021-12-20 21:07:31
 * @LastEditTime: 2022-01-05 07:29:00
 * @FilePath: \novel-serve\src\app\index.js
 */
const Koa = require('koa');
const bodyParser = require('koa-bodyparser');
const userRouter = require("../router");//导入路由入口函数
const errorHandle = require("./error-handle");//错误处理
const { sessionConfig } = require("./session-config");
const session = require("koa-session");

require('./database');//连接数据库

const app = new Koa();

app.use(bodyParser());//解析url参数和请求体等数据

//session配置
app.keys = ['some secret hurr'];
app.use(session(sessionConfig, app));


userRouter(app);

//监听错误
app.on('error', errorHandle)

module.exports = app;
